﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace FourSquareAPI
{
    public class checkin
    {
        private string _id;
        private user _user;
        private venue _venue;
        private string _display;
		private string _shout;
        private DateTime _created;
        private string _message;
        private mayor _mayor;
        private List<badge> _badges;
        private List<score> _scoring;
        private List<special> _specials;

        public checkin(XmlNode Xml)
        {
            XmlNodeList xnl = Xml.ChildNodes;

            foreach (XmlNode xn in xnl)
            {
                switch (xn.Name)
                {
                    case "id":
                        this._id = xn.InnerText;
                        break;
                    case "user":
                        this._user = new user(xn);
                        break;
                    case "venue":
                        this._venue = new venue(xn);
                        break;
                    case "display":
                        this._display = xn.InnerText;
                        break;
                    case "shout":
                        this._shout = xn.InnerText;
                        break;
                    case "created":
                        this._created = DateTime.Parse(xn.InnerText);
                        break;
                    case "message":
                        this._message = xn.InnerText;
                        break;
                    case "mayor":
                        this._mayor = new mayor(xn);
                        break;
                    case "badges":
                        this._badges = new List<badge>();
                        foreach (XmlNode badge in xn.ChildNodes)
                        {
                            this._badges.Add(new badge(badge));
                        }
                        break;
                    case "scoring":
                        this._scoring = new List<score>();
                        foreach (XmlNode score in xn.ChildNodes)
                        {
                            this._scoring.Add(new score(score));
                        }
                        break;
                    case "specials":
                        this._specials = new List<special>();
                        foreach (XmlNode special in xn.ChildNodes)
                        {
                            this._specials.Add(new special(special));
                        }
                        break;
                }
            }
        }

        public string Id
        {
            get
            {
                return this._id;
            }
        }

        public user User
        {
            get
            {
                return this._user;
            }
        }

        public venue Venue
        {
            get
            {
                return this._venue;
            }
        }
        public string Display
        {
            get
            {
                return this._display;
            }
        }

        public string Shout
        {
            get
            {
                return this._shout;
            }
        }

        public DateTime Created
        {
            get
            {
                return this._created;
            }
        }

        public string Message
        {
            get
            {
                return this._message;
            }
        }

        public mayor Mayor
        {
            get
            {
                return this._mayor;
            }
        }
        public List<badge> Badges
        {
            get
            {
                return this._badges;
            }
        }

        public List<score> Scoring
        {
            get
            {
                return this._scoring;
            }
        }

        public List<special> Specials
        {
            get
            {
                return this._specials;
            }
        }
    }
}
